package cn.school.entity;
import java.util.*;
//一页封装成一个类
public class Page2<T> {
    private int pageNo=1;//页号
    private int totalLines;//总条数
    private int totalPage;//总页数
    private int pageSize;//页大小

    private List<T> datas=new ArrayList<>(0);
    public Page2(){}

    public Page2(int pageNo, int totalLines, int pageSize, List<T> datas) {
        this.pageNo = pageNo;
        this.pageSize = pageSize;
        //this.totalLines = totalLines;
        this.setTotalLines(totalLines);

        this.datas = datas;
    }

    public int getPageNo() {
        return pageNo;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }

    public int getTotalLines() {
        return totalLines;
    }

    public void setTotalLines(int totalLines) {
        this.totalLines = totalLines;
        this.totalPage=this.totalLines/this.pageSize+(this.totalLines%this.pageSize==0?0:1);
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public List<T> getDatas() {
        return datas;
    }

    public void setDatas(List<T> datas) {
        this.datas = datas;
    }

    @Override
    public String toString() {
        return "Page2{" +
                "pageNo=" + pageNo +
                ", totalLines=" + totalLines +
                ", totalPage=" + totalPage +
                ", pageSize=" + pageSize +
                ", datas=" + datas +
                '}';
    }
}
